﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Marbles.Web.Admin.Content
{
    public partial class ControlPanel : ContentBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            cIbExplorer.Visible = false;
            cLbExplorer.Visible = false;
            cIbBackup.Visible = false;
            cLbBackup.Visible = false;

            if (Page.AuthenticationProvider.IsAuthenticated)
            {
                cIbExplorer.Visible = Page.AuthenticationProvider.CurrentToken.IsRoot;
                cLbExplorer.Visible = cIbExplorer.Visible;
                cIbBackup.Visible = cIbExplorer.Visible;
                cLbBackup.Visible = cIbExplorer.Visible;
                cIbModules.Visible = cIbExplorer.Visible;
                cLbModules.Visible = cIbExplorer.Visible;
            }
        }

        protected void Page_Command(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "System":
                    Response.Redirect("/Admin/Default.aspx?page=System", true);
                    break;
                case "Themes":
                    Response.Redirect("/Admin/Default.aspx?page=Themes", true);
                    break;
                case "Profiles":
                    Response.Redirect("/Admin/Default.aspx?page=Profiles", true);
                    break;
                case "Templates":
                    Response.Redirect("/Admin/Default.aspx?page=Templates", true);
                    break;
                case "ProfileQuestions":
                    Response.Redirect("/Admin/Default.aspx?page=ProfileQuestions", true);
                    break;
                case "CDN":
                    Response.Redirect("/Admin/Default.aspx?page=CDN", true);
                    break;
                case "Forum":
                    Response.Redirect("/Admin/Default.aspx?page=BBS", true);
                    break;
                case "Explorer":
                    Response.Redirect("/Admin/Explorer.aspx", true);
                    break;
                case "Modules":
                    Response.Redirect("/Admin/Default.aspx?page=Modules", true);
                    break;
                case "UrlShort":
                    Response.Redirect("/Admin/Default.aspx?page=UrlShort", true);
                    break;
                case "Backup":
                    Response.Redirect("/Admin/Downloads/backup.ashx?id=" + this.CurrentWeb.SiteId, true);
                    break;
            }
        }
    }
}